package cn.itcast.order;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

// 配置类的方式开启全局日志记录
//@EnableFeignClients(defaultConfiguration = DefaultFeignConfiguration.class)
// 开启feign客户端的支持
@EnableFeignClients(basePackages = "cn.itcast.feign")
@MapperScan("cn.itcast.order.mapper")
@SpringBootApplication
public class OrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class, args);
    }

    /**
     * 创建RestTemplate对象,用于远程访问
     * org.springframework.web.client.RestTemplate: spring-boot-starter-web包
     * @return
     */
    @Bean
    @LoadBalanced // 实现负载均衡
    public RestTemplate createRestTemplate(){
        return new RestTemplate();
    }

    /**
     * 修改负载均衡策略
     * @return
     */
//    @Bean
//    public IRule randomRule(){
//        return new RandomRule();
//    }
}